package com.emep.changzhi.analyse.service.Technology;

import com.emep.changzhi.analyse.entity.Technology.Desulphurization;
import com.emep.changzhi.analyse.repository.Technology.DesulphurizationRepository;
import com.emep.changzhi.analyse.utils.GsonUtils;
import com.emep.changzhi.analyse.utils.MapUtils;
import com.emep.changzhi.analyse.utils.UUIDTest;
import org.springframework.beans.factory.annotation.Autowired;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

/**
 * @author xy
 * @Description: 脱硫
 * @date 2018/8/28 16:15
 * @version V1.0
 */

@Slf4j
@Service
public class DesulphurizationService {
    @Resource
    private DesulphurizationRepository desulphurizationRepository;

    /**
     * @author xy
     * @Description: 新增
     * @date 2018/8/28 17:28
     * @version V1.0
     */

    public Desulphurization save(Map<String, Object> payload) {
        Desulphurization desulphurization = null;
        try {
            Desulphurization desulphurization1 = (Desulphurization) MapUtils.convertMap(Desulphurization.class,payload);
            desulphurization1.setId(UUIDTest.getUUID());
            desulphurization = desulphurizationRepository.save(desulphurization1);
        } catch (Exception e) {
            log.error(e.getClass().getName() + ":" + e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return desulphurization;
    }

    /**
     * @author xy
     * @Description: 首页
     * @date 2018/8/28 17:28
     * @version V1.0
     */
    public List<Desulphurization> finddesulphurizationByHome(Integer pageSize){
        List<Desulphurization> desulphurizations = null;
        try {
            desulphurizations = desulphurizationRepository.desulphurizationHome(pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return desulphurizations;

    }
    /**
     * @author xy
     * @Description: 翻页查询
     * @date 2018/8/28 17:28
     * @version V1.0
     */

    public List<Desulphurization> finddesulphurizationByFlip(String id,Integer pageSize) {
        List<Desulphurization> desulphurizations = null;
        try {
            desulphurizations = desulphurizationRepository.desulphurizationFlip(id,pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return desulphurizations;
    }
}
